import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: 'Login - 登录'
  },
  component: () => import('@/views/login.vue')
};

export const page404 = {
  path: '/*',
  name: 'error-404',
  meta: {
    title: '404-页面不存在'
  },
  component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
  path: '/403',
  meta: {
    title: '403-权限不足'
  },
  name: 'error-403',
  component: () => import('@/views/error-page/403.vue')
};

export const page500 = {
  path: '/500',
  meta: {
    title: '500-服务端错误'
  },
  name: 'error-500',
  component: () => import('@/views/error-page/500.vue')
};

export const preview = {
  path: '/preview',
  name: 'preview',
  component: () => import('@/views/form/article-publish/preview.vue')
};


// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
  path: '/',
  name: 'otherRouter',
  redirect: '/home',
  component: Main,
  children: [
    {
      path: 'home',
      title: '主页',
      name: 'home_index',
      component: () => import('@/views/home/home.vue')
    },
    {
      path: 'ownspace',
      title: '个人中心',
      name: 'ownspace_index',
      component: () => import('@/views/own-space/own-space.vue')
    },
    {
      path: 'message',
      title: '消息中心',
      name: 'message_index',
      component: () => import('@/views/message/message.vue')
    },
    {
      path: 'projectDetail/:projectId',
      title: '项目详情',
      name: 'project-detail',
      icon: 'compose',
      access: 1,
      component: () =>
        import('@/views/project/projectDetail.vue')
    },
    {
      path: 'tableDetails/:tableId',
      title: '申购表详情',
      name: 'table-details',
      icon: 'compose',
      access: 1,
      component: () =>
        import('@/views/project/tableDetails.vue')
    },
    {
      path: 'orderCheckM/:tableId',
      title: '申购表审核',
      name: 'order-check-m',
      icon: 'arrow-swap',
      access: 2,
      component: () => import('@/views/orderListM/projectCheck.vue')
    },
    {
      path: 'orderCheckC/:tableId',
      title: '申购表审核',
      name: 'order-check-c',
      icon: 'arrow-swap',
      access: 3,
      component: () => import('@/views/orderListC/projectCheck.vue')
    },
    {
      path: 'orderCheckStore/:tableId',
      title: '申购表审核',
      name: 'order-check-store',
      icon: 'arrow-swap',
      access: 4,
      component: () => import('@/views/storeManage/tableCheck.vue')
    }
  ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
  {
    path: '/project',
    icon: 'ios-infinite',
    name: 'project',
    title: '项目管理',
    access: 1,
    component: Main,
    children: [
      {
        path: 'projectManage',
        title: '项目列表',
        name: 'project-manage',
        icon: 'compose',
        access: 1,
        component: () =>
          import('@/views/project/projectManage.vue')
      },
      {
        path: 'storedTables',
        title: '已入库申购表',
        name: 'stored-tables',
        icon: 'compose',
        access: 1,
        component: () =>
          import('@/views/project/storedTables.vue')
      },
      {
        path: 'receiveTables',
        title: '我的领用表',
        name: 'receive-tables',
        icon: 'compose',
        access: 1,
        component: () =>
          import('@/views/project/receiveTable.vue')
      },
    ]
  },
  {
    path: '/order',
    icon: 'social-buffer',
    name: 'order-m',
    title: '申购表管理',
    access: 2,
    component: Main,
    children: [
      {
        path: 'orderListM',
        title: '部门主管申购表',
        name: 'order-list-m',
        icon: 'compose',
        access: 2,
        component: () => import('@/views/orderListM/order-list.vue')
      }
    ]
  },
  {
    path: '/order',
    icon: 'ios-infinite',
    name: 'order-c',
    title: '申购表管理',
    access: 3,
    component: Main,
    children: [
      {
        path: 'orderListC',
        title: '中心主管申购表1',
        name: 'order-list-c',
        icon: 'compose',
        access: 3,
        component: () => import('@/views/orderListC/order-list.vue')
      },

    ]
  },
  {
    path: '/repository',
    icon: 'android-checkbox',
    name: 'repository',
    title: '仓库管理',
    access: 4,
    component: Main,
    children: [
      {
        path: 'toInStorage',
        title: '待入库申购表',
        name: 'to-in-storage',
        icon: 'compose',
        access: 4,
        component: () =>
          import('@/views/storeManage/toStoreList.vue')
      },
      {
        path: 'storagedList',
        title: '已入库申购表',
        name: 'storaged-list',
        icon: 'compose',
        access: 4,
        component: () =>
          import('@/views/storeManage/storedList.vue')
      },
      {
        path: 'storeTypeList',
        title: '物品类型管理',
        name: 'store-type-list',
        icon: 'arrow-swap',
        access: 4,
        component: () => import('@/views/storeManage/storeTypeList.vue')
      },
      {
        path: 'toReceiveTables',
        title: '未审核领用表',
        name: 'to-receive-tables',
        icon: 'compose',
        access: 4,
        component: () =>
          import('@/views/storeManage/toReceiveTable.vue')
      },
      {
        path: 'dReceiveTables',
        title: '已通过领用表',
        name: 'd-receive-tables',
        icon: 'compose',
        access: 4,
        component: () =>
          import('@/views/storeManage/dReceiveTable.vue')
      },
    ]
  },
  {
    path: '/personnel',
    icon: 'compose',
    name: 'personnel',
    title: '人员管理',
    access: 5,
    component: Main,
    children: [
      {
        path: 'passwordManage',
        title: '密码更改',
        name: 'personnel1',
        access: 5,
        icon: 'compose',
        component: () => import('@/views/personal/password-manage.vue')
      },
      {
        path: 'personManage',
        title: '人员管理',
        access: 5,
        name: 'personnel2',
        icon: 'arrow-swap',
        component: () => import('@/views/personal/person-manage.vue')
      }
    ]
  }

];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
  loginRouter,
  otherRouter,
  preview,
  ...appRouter,
  page500,
  page403,
  page404
];